<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;


Route::get('hello/:name', 'index/hello');


/*======================= start 小程序公众平台 ========================*/
Route::group('platform',function(){

    //申请小程序页面
    Route::get('applyMiniProgram', 'platform/index/applyMiniProgram');
    //创建小程序
    Route::post('createMiniProgram', 'platform/index/createMiniProgram');
    //小程序开发文档
    Route::get('document', 'platform/index/document');


});
/*======================= start 小程序公众平台 ========================*/


/*======================= start 小程序微信api ========================*/

Route::group('login',function(){

    //获取token(没有登录的用户)
    Route::get('getToken', '\app\controller\applets\Login@getToken');
    //刷新token
    Route::post('refreshToken', '\app\controller\applets\Login@refreshToken');
    //检查token
    Route::post('verifyToken', '\app\controller\applets\Login@verifyToken');

});


Route::group('app',function(){

    //小程序列表
    Route::post('miniapplist', '\app\controller\applets\Index@miniapplist');
    //消息
    Route::post('message', '\app\controller\applets\Index@message');

})->middleware(['appAuth','tokenBucket']);

//不对外只在app中调用
Route::group('system',function(){

    //获取小程序信息
    Route::get('getminiprograminfo', '\app\controller\applets\System@getminiprograminfo');
    //下载小程序源码
    Route::post('downsource', '\app\controller\applets\System@downsource');

});

//在开发者工具中使用的接口
Route::group('devtool',function(){

    //上传提交小程序源码
    Route::post('commitsource', '\app\controller\applets\System@commitsource');

});

//服务端对外的接口
Route::group('mpapi',function(){

    //小程序登录获取openid
    Route::get('jscode2session', '\app\controller\applets\Sys@jscode2session');

});

/*======================= end 小程序微信api ========================*/



//模拟数据生成器，可以生成随机数据
Route::group('mock',function(){

    //生成一条数据
    Route::any('api/queryData', '\app\controller\applets\Mock@queryData');

    //生成列表数据
    Route::any('api/listData', '\app\controller\applets\Mock@listData');

    //修改数据
    Route::any('api/updateData', '\app\controller\applets\Mock@updateData');

})->middleware('cors');
